import java.awt.Color;
import java.awt.Cursor;
import java.awt.EventQueue;

import javax.swing.*;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class ModeSelectionUI extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					ModeSelectionUI frame = new ModeSelectionUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ModeSelectionUI() {
		getContentPane().setLayout(null);
		setTitle("Choose Mode");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 700, 490);
		this.contentPane =  new JPanel();
		this.contentPane.setBackground(Color.WHITE); //default
		setContentPane(contentPane);
		contentPane.setLayout(null);
		ImageIcon singlePlayerPic = new ImageIcon("Graphics/SinglePlayerButton.png");
		ImageIcon multiplayerPic = new ImageIcon("Graphics/MultiplayerButton.png");
		ImageIcon filipinopolyPic = new ImageIcon("Graphics/FilipinopolyLabel.png");
		ImageIcon mascotPic = new ImageIcon("Graphics/Mascot.png");
		JLabel filipinopolyLabel = new JLabel(filipinopolyPic);
		JButton loadButton = new JButton(mascotPic);
		JButton singlePlayerButton = new JButton(singlePlayerPic);
		JButton multiplayerButton = new JButton(multiplayerPic);
		singlePlayerButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				
				singlePlayerButtonActionPerformed(e);
				
			}
		});
		multiplayerButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				
				multiplayerButtonActionPerformed(e);
				
			}
		});
		
		loadButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				
				loadButtonActionPerformed(e);
				
			}
		});
		
		contentPane.add(multiplayerButton);
		contentPane.add(singlePlayerButton);
		contentPane.add(filipinopolyLabel);
		contentPane.add(loadButton);
		
		multiplayerButton.setBounds(436, 99, 238, 350);
		multiplayerButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
		singlePlayerButton.setBounds(10, 102, 240, 343);
		singlePlayerButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
		filipinopolyLabel.setBounds(85, 10 ,511, 94);
		loadButton.setBounds(300, 170, 114, 139);
		loadButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
		//set buttons invisible
		multiplayerButton.setBorderPainted(false);
		multiplayerButton.setContentAreaFilled(false);
		multiplayerButton.setOpaque(false);
		singlePlayerButton.setBorderPainted(false);
		singlePlayerButton.setContentAreaFilled(false);
		singlePlayerButton.setOpaque(false);
		loadButton.setBorderPainted(false);
		loadButton.setContentAreaFilled(false);
		loadButton.setToolTipText("Load Game");
		//load button
		loadButton.setRolloverEnabled(true);
		loadButton.setRolloverIcon(new ImageIcon("Graphics/MascotRollOver.png"));
		//end of setting visibility
		
		//Jarvis jarvis = new Jarvis();
		
	}
	
	private void singlePlayerButtonActionPerformed(ActionEvent e){
		
		Player p[] = new Player[1];
		p[0] = new Player();
		BoardUI board = BoardUI.getInstance(p);
		this.dispose();
		
	}
	private void loadButtonActionPerformed(ActionEvent e){
		
		new LoadGameUI();
		this.dispose();
		
	}
	
	private void multiplayerButtonActionPerformed(ActionEvent e){
		
		
		MultiplayerUI multiplayerUI = new MultiplayerUI();
		multiplayerUI.setVisible(true);
		this.dispose();
		
	}
	
	
}
